package com.huixh.train.business.controller.admin;

import com.huixh.train.business.req.DailyTrainCarriageQueryReq;
import com.huixh.train.business.req.DailyTrainCarriageSaveReq;
import com.huixh.train.business.resp.DailyTrainCarriageQueryResp;
import com.huixh.train.business.service.DailyTrainCarriageService;
import com.huixh.train.common.resp.PageResult;
import com.huixh.train.common.resp.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
* @author huixh
*/
@Tag(name = "每日车次车厢")
@Validated
@RestController
@RequestMapping("/admin/dailyTrainCarriage")
public class DailyTrainCarriageController {
    @Resource
    private DailyTrainCarriageService dailyTrainCarriageService;

    @PostMapping("/save")
    @Operation(summary = "新增/编辑")
    public Result<?> save(@RequestBody @Valid DailyTrainCarriageSaveReq dailyTrainCarriageSaveReq) {
    dailyTrainCarriageService.save(dailyTrainCarriageSaveReq);
        return Result.success();
    }
    @Operation(summary = "查询列表")
    @PostMapping("/quest-list")
    public PageResult<List<DailyTrainCarriageQueryResp>> query(@RequestBody @Valid DailyTrainCarriageQueryReq dailyTrainCarriageQueryReq) {
        return dailyTrainCarriageService.queryList(dailyTrainCarriageQueryReq);
    }
    @Operation(summary = "删除")
    @DeleteMapping("/delete/{id}")
    public Result<?> deleteById(@NotNull @PathVariable(name = "id") Long id) {
        dailyTrainCarriageService.delete(id);
        return Result.success("删除成功");
    }
}